﻿using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.Common
{
    public static class BaseResult
    {
        public static JsonResult Success(object data)
        {
            return new JsonResult(new ApiResult()
            {
                code = "200",
                message = "操作成功！",
                data = data,
                count = 0
            });
        }
        public static JsonResult Success(string message = "操作成功!")
        {
            return new JsonResult(new ApiResult()
            {
                code = "200",
                message = message,
                data = null,
                count = 0
            });
        }
        public static JsonResult Fail(string message = "操作失败!")
        {
            return new JsonResult(new ApiResult()
            {
                code = "500",
                message = message,
                data = null,
                count = 0
            });
        }
        public static ApiResult Result(object data, string message, string code, int count = 0)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.message = message;
            result.data = data;
            result.count = count;
            return result;
        }
        public static ApiResult Result(object data, string code, int count)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.data = data;
            result.count = count;
            return result;
        }
        public static ApiResult Result(object data, string code)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.data = data;
            return result;
        }
        public static ApiResult Result(string code, string message)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.message = message;
            return result;
        }
    }
}
